/**
 * TimeCoster.java
 */
package com.mht2017.common.utils;

public class TimeCoster {

	private long start;
	private long end;

	public TimeCoster() {
		start();
	}

	public long start() {
		return start = System.currentTimeMillis();
	}

	public long end() {
		return end = System.currentTimeMillis();
	}

	public long costByMillis() {
		checkEnd();
		return end - start;
	}

	public long costByMillisForceEnd() {
		end();
		return end - start;
	}

	public long costBySecond() {
		checkEnd();
		return (end - start) / 1000;
	}

	public long costBySecondForceEnd() {
		end();
		return (end - start) / 1000;
	}

	private void checkEnd() {
		if (0 == end) {
			end();
		}
	}

}
